package com.brucekong.slm.service.content;

import com.brucekong.slm.mapper.content.ArticleMapper;
import com.brucekong.slm.model.content.ArticleDomain;
import com.brucekong.slm.model.content.CommentDomain;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    public PageInfo<ArticleDomain> getArticleList(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<ArticleDomain> articleDomainsList = articleMapper.getArticleList(page, limit);
        return new PageInfo<>(articleDomainsList);
    }

    public PageInfo<Map> getTagsList(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<Map> tags = articleMapper.getTagsList(page, limit);
        return new PageInfo<>(tags);
    }

    public PageInfo<CommentDomain> getCommentsList(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<CommentDomain> commentDomainList = articleMapper.getCommentsList(page, limit);
        return new PageInfo<>(commentDomainList);
    }
}